/*
* @Author: dengjiayao
* @Date:   2017-06-26 09:17:32
 * @Last Modified by: songwh
 * @Last Modified time: 2018-03-26 14:40:54
*/

import { modal } from 'vue-strap'
import { addCastTalkItem, showMsg } from '../../vuex/action'

export default {
  name: 'classification-config',
  data() {
    return {
      showModal: false,
      actionType: 'ADD', // ADD or UPDATE
      form: {
        name: ''
      }
    }
  },
  components: {
    'vue-modal': modal
  },
  vuex: {
    actions: {
      xCreate: addCastTalkItem,
      xShowMsg: showMsg
    }
  },
  methods: {
    submit() {
      if(!this.form.name){
        return this.xShowMsg({
          type: 'danger',
          content: '*标为必填项'
        })
      }
      let params = {
        name: this.form.name
      }
      return this.xCreate(params)
        .then(() => {
          this.showModal = false
        })
        .catch((res) => {
          this.xShowMsg({
            type: 'danger',
            content: res.error_msg
          })
        })
    }
  }
}
